package org.test;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class MulThread implements Runnable {
	Socket socket = null;

	public MulThread(Socket socket) {
		this.socket = socket;
	}

	@Override
	public void run() {
		OutputStream os = null;
		InputStream is = null;
		StringBuffer sb = new StringBuffer();
		try {
			is = socket.getInputStream();
			os = socket.getOutputStream();
			byte[] buffer = new byte[1024];
			int len = 0;
			while ((len = is.read(buffer)) != -1) {
				os.write(len);
				sb.append(new String(buffer, 0, len));
			}
			System.out.println("Client: " + sb.toString());
			is.close();
			os.close();
			socket.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
